{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Worked solution to linear regression lab 1\n",
    "---"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Step 1: load the data - I'll use numpy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "in_data = np.loadtxt('data100m.csv',delimiter=',')\n",
    "x = in_data[:,0] # year\n",
    "t = in_data[:,1] # winning time"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Step 2: plot the data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pylab as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.text.Text at 0x10832f090>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZMAAAEPCAYAAACHuClZAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAG/VJREFUeJzt3X2QZHV97/H3Z0AuDA+K+AABWUQYuK7CDAPrA2YZTS6g\nITyFQjAadFOGxFxkY2KASqp2Sd2bANeYJVImiLubNcpFESIP8QFQR4KIkNkZWJZ9IAUsz4sVnpYs\ncnH6e/84Z3Z7h56Z03O6+5zT83lVddH963NOf2fY09/5PSsiMDMzy6On6ADMzKz6nEzMzCw3JxMz\nM8vNycTMzHJzMjEzs9ycTMzMLLe2JhNJyyVtlnRfXdllktZJGpN0naS9pjj3REnrJW2UdEE74zQz\ns3zaXTNZCZwwqewWYH5E9AMPAhdNPklSD3BFeu584GxJh7c5VjMzm6W2JpOIuAN4blLZbRFRS1/e\nBRzQ4NQFwIMRs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69PrraHBCs9m\nreZkYt1sPjBSXxARW4BNJGsoTZQF8M/Ax9Oi3wTGIuI/09dviIj3AZ8jWefobyPincARko5Ij9md\nZE2mdwG3kyzPso2k1wHXAOdFRH/6GS9Pinc5yfIjSNoLeB/wr8DvA89HxHuABcAfSJqXnn9qRBxN\nssbV39Zd6xDgioh4d0TUL5Fu1hZOJjYXNWr2WQl8In2+KH09YaJfZQ3wdEQ8kL5eS7K7HiSbt30r\nff51kh0H6x0GPBkRqyHZvCiS1XK3iYjbgUPSWs3ZwHXpMccDvydplGQHvDcCh5Lcv5dIupdk7aVf\nkzSxV8Wm2L65kVnbVWkJerNmPQCcUV+Q/sX/NpKF+faZKI+Ix5XsXf5B4BiSBRQnvJL+t1b3fOL1\nVPdQo76YLH0XXyNJamexfaVXkdRobp30s5yT/gwDEVGT9DAw0Xz3Xxk+y6xlXDOxrhURPwR2k/Rx\nACXbw34BWBkRv2xwynKSWsW3YuoVUKdKCD1sT1y/S7InR70NwL6SBtNY9kiXZJ9sFbA4CT/Wp2U/\nAD5TNwrtUEm9JNtYP5Mmkg8C8zLEadYWTibW7U4DzpS0kWQJ9JdJlt5u5EaSvo9/qiubbpe6+uf/\nRbL39xpgCPir+mMi2Q71o8AVksZIlgLflUki4hmSpczrm9m+SlLLWp1e/x+BnUg2wTombeb6eHre\nVHGbtZWXoDdLSTqapHP9uFmcuyUi9mxBDL3AvcBR6WABs0pwzcQMkHQBcC1w4SwvkfuvMiU7iD4A\n/L0TiVWNayZmZpabayZmZpabk4mZmeXmZGJmZrk5mZiZWW5OJmZmlpuTiZmZ5fb/AfGDlv/EJvQ6\nAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1058c3150>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(x,t,'ro')\n",
    "plt.xlabel('Olympic year')\n",
    "plt.ylabel('Winning time') # It's always a good idea to label the axes..."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Step 3: compute the necessary values for $w_0$ and $w_1$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "xbar = x.mean()\n",
    "tbar = t.mean()\n",
    "xxbar = (x*x).mean()\n",
    "xtbar = (x*t).mean()\n",
    "\n",
    "w_1 = (xtbar - xbar*tbar)/(xxbar - xbar*xbar)\n",
    "w_0 = (t - w_1*x).mean()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Step 4: make the new plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x10832af90>]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAEACAYAAACznAEdAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmcFNW5//HPM6DXtBqFqHFBQIRhE5lhIhoXmJjELe56\njcvNT8V7RY0LCojEBRSN4o0GE/dliFEJKpho3NeBHxqvMMywCYwx1wWjuCGKiJDp5/5xCmxwlp6Z\n7q7ume/79eoX3dVVXc8MdH2pOnXOMXdHRESkKO4CREQkPygQREQEUCCIiEhEgSAiIoACQUREIgoE\nEREB0ggEM7vHzJab2fyUZdeb2WIzqzGz6Wb23Qa2PcTMlphZrZmNyWThIiKSWemcIUwGDt5k2bNA\nf3cvAd4Axm66kZkVATdH2/YHTjKzPq0rV0REsqXJQHD3WcCKTZY97+7J6OWrQJd6Nh0MvOHub7v7\nOmAqcFQr6xURkSzJRBvCMOCpepbvAryb8npZtExERPJQqwLBzC4F1rn7lAzVIyIiMenY0g3N7DTg\nMODABlZ5D+ia8rpLtKyhz9OgSiIizeTulqnPSvcMwaJHeGF2CDAaONLdv25g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D+FLgWWDblG3y4vvb3Noz/d1VxzQREQE0haaIiEQUCCIiAigQ\nREQkokAQERFAgSAiIhEFgoiIAAoEERGJKBBERASA/wPQnuUxcdo+pAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x10833fc50>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure()\n",
    "plt.plot(x,t,'ro')\n",
    "plt.plot([x[0],x[-1]],[w_0 + w_1*x[0],w_0 + w_1*x[-1]],'b')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "Step 5: quadratic!\n",
    "Derivation is theoretically easy but a pain as it involves solving a system of three simultaneous equations (we'll see how to make it easy next time). Probably the easiest way to do it is through gaussian elimination of the following matrix system (see e.g. [https://www.math.hmc.edu/calculus/tutorials/linearsystems/]()). The matrix system is obtained by differentiating with respect to $w_0$, $w_1$ and $w_2$."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$ Aw = b $$\n",
    "\n",
    "where\n",
    "\n",
    "$$ A = \\left[ \\begin{array}{ccc} 1 & \\bar{x} & \\bar{x^2} \\\\\n",
    "                                \\bar{x} & \\bar{x^2} & \\bar{x^3} \\\\\n",
    "                                \\bar{x^2} & \\bar{x^3} & \\bar{x^4}\n",
    "               \\end{array}\\right] $$\n",
    "            \n",
    "$$ w = \\left[ \\begin{array}{c} w_0 \\\\ w_1 \\\\ w_2 \\end{array}\\right] $$\n",
    "\n",
    "and \n",
    "\n",
    "$$ b = \\left[ \\begin{array}{c} \\bar{t} \\\\ \\bar{xt} \\\\ \\bar{x^2t} \\end{array}\\right] $$\n",
    "\n",
    "and \n",
    "\n",
    "$$ \\bar{f} = \\frac{1}{N}\\sum_{n=1}^N f_n $$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "tbar = t.mean()\n",
    "xbar = x.mean()\n",
    "x2bar = (x*x).mean()\n",
    "x3bar = (x*x*x).mean()\n",
    "x4bar = (x*x*x*x).mean()\n",
    "x2tbar = (x*x*t).mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.000110151552656\n",
      "-0.443160488183\n",
      "455.597858393\n"
     ]
    }
   ],
   "source": [
    "num = x2tbar - x2bar*tbar - (x3bar-x2bar*xbar)*(xtbar-xbar*tbar)/(x2bar-xbar*xbar)\n",
    "den = x4bar - x2bar*x2bar - (x3bar-x2bar*xbar)*(x3bar-x2bar*xbar)/(x2bar-xbar*xbar)\n",
    "w_2 = num/den\n",
    "print w_2\n",
    "w_1 = (xtbar-xbar*tbar)/(x2bar-xbar*xbar) - w_3*(x3bar-xbar*x2bar)/(x2bar-xbar*xbar)\n",
    "print w_1\n",
    "w_0 = tbar - w_1*xbar - w_2*x2bar\n",
    "print w_0"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Make the new plot..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.text.Text at 0x108dc5890>"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZMAAAEPCAYAAACHuClZAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl41OW5//H3HUAhLAq44HEBFyLKERKjuGPcQRHXWvXY\nWrFWa134tbboaS3Y9mfd6kFt3QmuuGLFXdQaUVu3kCgim0dEcaEqoiKomLnPH883OMRJmGSW70zy\neV3XXMw8813uADN3nt3cHRERkUyUxB2AiIgUPyUTERHJmJKJiIhkTMlEREQypmQiIiIZUzIREZGM\n5TSZmNkkM1ti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j4/F5kZq8S1l76DzNr3KtikX+3uZFIzhXTEvQirfUGcHRyQfQb/+aEhfn6Npa7+2IL\ne5fvA+xMWECx0dfRn4mk542vm/sMpeqLSafv4hZCUjuW71Z6NUKN5okmP8uJ0c9Q4e4JM1sINDbf\nfZnGvUSyRjUTabfc/Smgm5mdAGBhe9jLgMnu/lWKUyYRahV3e/MroDaXEEr4LnH9F2FPjmTzgH5m\nVhnF0iNakr2pm4GxIXyfG5U9DpyeNAptoJmVErax/neUSPYB+qcRp0hOKJlIe3cEcIyZzScsgb6S\nsPR2Kg8Q+j5uSipraZe65OdfEvb+ngVUAX9IPsbDdqg/BP5qZvWEpcC70oS7/5uwlHlyM9uNhFrW\nzOj61wKdCJtg7Rw1c50Qnddc3CI5pSXoRSJmthOhc33vNpz7hbv3zEIMpcCrwI7RYAGRoqCaiQhg\nZuOAe4Bz23iJjH8rs7CD6BvAlUokUmxUMxERkYypZiIiIhlTMhERkYwpmYiISMaUTEREJGNKJiIi\nkjElExERydj/ARM8gsn60rmkAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x108afcf10>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure()\n",
    "xvals = np.linspace(x[0],x[-1],100)\n",
    "tvals = w_0 + w_1*xvals + w_2*xvals**2\n",
    "plt.plot(x,t,'ro')\n",
    "plt.plot(xvals,tvals,'b')\n",
    "plt.xlabel('Olympic year')\n",
    "plt.ylabel('Winning time')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
